
package com.epam.android.training.app.activities;

import com.epam.android.training.app.R;

import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

/**
 * Activity with menu. All other activities will extend this class.
 * 
 * @author Natallia_Kukharchyk
 */
public class ActivityWithMenu extends Activity {

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = new MenuInflater(getApplicationContext());
    inflater.inflate(R.menu.main_menu, menu);
    return true;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    Intent i;
    switch (item.getItemId()) {
      case R.id.about:
        i = new Intent(getApplicationContext(), AboutActivity.class);
        startActivity(i);
        break;
      case R.id.news:
        i = new Intent(getApplicationContext(), NewsActivity.class);
        startActivity(i);
        break;
      case R.id.tests:
        i = new Intent(getApplicationContext(), TestListActivity.class);
        startActivity(i);
        break;
      case R.id.settings:
        i = new Intent(getApplicationContext(), SettingsActivity.class);
        startActivity(i);
        break;
    }
    return true;
  }
}
